package com.ipDev.moyvSys.config;

import com.ipDev.moyvSys.interceptor.JwtTokenEmpInterceptor;
import com.ipDev.moyvSys.interceptor.JwtTokenUserInterceptor;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

@Configuration
@Slf4j
@RequiredArgsConstructor
public class WebMvcConfiguration extends WebMvcConfigurationSupport {
    private final JwtTokenEmpInterceptor jwtTokenEmpInterceptor;

    private final JwtTokenUserInterceptor jwtTokenUserInterceptor;

    protected void addInterceptors(InterceptorRegistry registry) {
        log.info("开始注册自定义拦截器");
        registry.addInterceptor(jwtTokenUserInterceptor)
                .addPathPatterns("/user/**")
                .excludePathPatterns("/user/user/login");
        registry.addInterceptor(jwtTokenEmpInterceptor)
                .addPathPatterns("/emp/**")
                .excludePathPatterns("/emp/emp/login");
    }
}
